package com.lt73.springplugin;

import com.lt73.springplugin.config.BeanConfig;
import com.lt73.springplugin.service.SmsService;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.plugin.core.PluginRegistry;

import java.util.List;

@SpringBootApplication
public class SpringPluginDemoApplication {

    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(BeanConfig.class);
        PluginRegistry<SmsService, String> registry = context.getBean(PluginRegistry.class);
        List<SmsService> plugins = registry.getPlugins();
        for (SmsService plugin : plugins) {
            plugin.sendSms("1391xxxxxxxx");
            plugin.sendSms("1381xxxxxxxx");
        }
    }

}
